{
  //声明一个接口  interface 接口  重点 重点 重点
  //接口好比是一个标准
  interface BoyFriend{
    readonly id: number;
    name: string;
    age: number;
    car ?: string;
    // cook ?: () => void; //void 是函数返回值的类型
    cook(): void;//number 是函数的返回值类型
  }

  //声明一个变量
  let me:BoyFriend = {
    id: 1,
    name: '张三',
    age: 36,
    car: '雅迪',
    cook(){
      console.log('我会做泡面');
    }
  };

  let you:BoyFriend = {
    id: 2,
    name: '旭鹏',
    age: 18,
    cook: () => {
      console.log('我会做黯然销魂饭...');
    }
  };

  //修改 id 属性值
  // me.id = 123;
}

{
  // 类与接口
  interface BoyFriend{
    name: string;
    age: number;
    car ?: string;
    cook : (fan: string) => void;
  }

  //implements 实现
  class LeBoy implements BoyFriend {
    //属性
    name: string;
    age: number;
    car?: string;
    house: string = '120m2';

    //构造方法
    constructor(name: string, age: number, car?: string){
      this.name = name;
      this.age = age;
      this.car = car;
    }

    cook(fan: string){
      console.log('我可以做' + fan);
    }

    earn(){
      console.log('能挣钱...');
    }
  }

  //实例化对象
  let wjk:BoyFriend = new LeBoy('王俊凯', 22, '五菱mini');

}

{
  //一个类可以实现多个接口   『接口继承』
  interface BaseInfo{
    name: string;
    age: number;
  }

  interface Test{
    test: number;
  }

  // 类与接口
  interface BoyFriend extends BaseInfo, Test{
    car ?: string;
    cook : (fan: string) => void;
  }

  //另一个接口
  interface Programmer extends BaseInfo{
    language: string;
    program: (lang: string) => void;
  }

  //implements 实现
  class LeBoy implements BoyFriend, Programmer {
    //属性
    name: string;
    age: number;
    car?: string;
    language: string;
    house: string = '120m2';
    test: number = 520

    //构造方法
    constructor(name: string, age: number, language: string, car?: string){
      this.name = name;
      this.age = age;
      this.language = language
      this.car = car;
    }

    cook(fan: string){
      console.log('我可以做' + fan);
    }

    //编程方法
    program(lang: string){
      console.log(`我可以编写 ${lang} 语言`)
    }

    earn(){
      console.log('能挣钱...');
    }
  }

  //实例化对象
  let me = new LeBoy('佳乐', 18, 'JavaScript', '爱玛');

  console.log(me);
  
}

{
  //接口的重复声明
  interface A{
    name: string;
    age: number;
  }

  interface A{
    height: number;
    weight: number;
  }

  let test:A = {
    name: 'xxx',
    age: 20,
    height: 10,
    weight: 20
  }
}

{
  interface Zuoyi{
    color: string;
    caizhi: string;
    num: number
  }

  interface Car{
    brand: string;
    price: number;
    color: string;
    zuoyi: Zuoyi
  }

  //接口
  interface A{
    name: string;
    car: Car
  }

  let person:A = {
    name: '王五',
    car: {
      brand: '比亚迪',
      price: 120000,
      color: 'blue',
      zuoyi: {
        color: '黑色',
        caizhi: '真皮',
        num: 5
      }
    }
  }

}